#!usr/bin/env python  
# -*- coding:utf-8 _*-
""" 
@author:robot
@file: case03_v1.py 
@version:
@time: 2022/05/12 
"""
from TapClientCaseData.CaseGenerateData import CGB
from TapClientCaseData.CaseGenerateData.case_generator.case_data_generate_base import *
from TapDataSourceInfo import db_info_v124


class CaseGenerate01(CGB):
    CGB_SOURCE = read_yaml(path_joint(CASE_GENERATE_SOURCE, 'source01.yml'))
    CGB_TARGET = read_yaml(path_joint(CASE_GENERATE_TARGET, 'target01.yml'))
    CGB_STATS = CASE_GENERATE_STATS
    # NODE NAME
    _CGBS_MYSQL = CGB_SOURCE.get('Mysql')
    _CGBS_ORACLE = CGB_SOURCE.get('Oracle')
    _CGBS_MONGODB = CGB_SOURCE.get('MongoDB')
    _CGBS_DB2 = CGB_SOURCE.get('DB2')
    _CGBS_POSTGRES = CGB_SOURCE.get('Postgres')
    _CGBS_SQLSERVER = CGB_SOURCE.get('Sqlserver')
    #
    _CGBS_GBASE8S = CGB_SOURCE.get('Gbase8s')
    _CGBS_SYBASE = CGB_SOURCE.get('Sybase')
    _CGBS_GAUSSDB200 = CGB_SOURCE.get('GaussDB200')
    _CGBS_KAFKA = CGB_SOURCE.get('Kafka')
    _CGBS_MARIADB = CGB_SOURCE.get('MariaDB')
    #
    _CGBS_MQ = CGB_SOURCE.get('MQ')
    _CGBS_GREENPLUM = CGB_SOURCE.get('Greenplum')
    _CGBS_HANA = CGB_SOURCE.get('HANA')
    _CGBS_DUMMY = CGB_SOURCE.get('Dummy')
    # CASE DATA
    CGBS_MYSQL = static_add_db_info_name(MYSQL_GENERATE_STATIC, _CGBS_MYSQL)
    CGBS_ORACLE = static_add_db_info_name(ORACLE_GENERATE_STATIC, _CGBS_ORACLE)
    CGBS_MONGODB = static_add_db_info_name(MONGODB_GENERATE_STATIC, _CGBS_MONGODB)
    CGBS_DB2 = static_add_db_info_name(DB2_GENERATE_STATIC, _CGBS_DB2)
    CGBS_POSTGRES = static_add_db_info_name(POSTGRES_GENERATE_STATIC, _CGBS_POSTGRES)
    CGBS_SQLSERVER = static_add_db_info_name(SQLSERVER_GENERATE_STATIC, _CGBS_SQLSERVER)

    CGBS_GBASE8S = static_add_db_info_name(MYSQL_GENERATE_STATIC, _CGBS_GBASE8S)
    CGBS_SYBASE = static_add_db_info_name(SQLSERVER_GENERATE_STATIC, _CGBS_SYBASE)
    CGBS_GAUSSDB = static_add_db_info_name(POSTGRES_GENERATE_STATIC, _CGBS_GAUSSDB200)
    CGBS_KAFKA = static_add_db_info_name(KAFKA_GENERATE_STATIC, _CGBS_KAFKA)
    CGBS_MARIADB = static_add_db_info_name(MYSQL_GENERATE_STATIC, _CGBS_MARIADB)
    #
    CGBS_MQ = static_add_db_info_name(DEFAULT, _CGBS_MQ)
    CGBS_GREENPLUM = static_add_db_info_name(POSTGRES_GENERATE_STATIC, _CGBS_GREENPLUM)
    CGBS_HANA = static_add_db_info_name(DEFAULT, _CGBS_HANA)
    CGBS_DUMMY = static_add_db_info_name(DEFAULT, _CGBS_DUMMY)

    # db_info class
    db_info_class = get_classes(db_info_v124)
    # ddl,dml class
    dml_ddl_base = get_classes(base00_common)

    @property
    def cgb_source(self):
        return self._assemble_source()

    def assemble_target(self):
        target_info = {}
        target = self.target
        for _type, name in target.items():
            target_info[_type] = getattr(self.db_info_class.get(_type), name)
        return target_info

    def cgb_sybase(self, case='demo', _type='dataflow'):
        return self.assemble(self.CGBS_SYBASE, case, _type)

    def cgb_mq(self, case='demo', _type='dataflow'):
        return self.assemble(self.CGBS_MQ, case, _type)

    def cgb_hana(self, case='demo', _type='dataflow'):
        return self.assemble(self.CGBS_HANA, case, _type)

    def cgb_dummy(self, case='demo', _type='dataflow'):
        return self.assemble(self.CGBS_DUMMY, case, _type)


if __name__ == '__main__':
    T = CaseGenerate01()
    pprint(T.cgb_mysql())
